import request from '@/utils/request.js'
// import store from '../store'
// 用户登录
export const LoginAPI = ({ mobile, code }) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}

// 获取频道
export const channelListAPI = () => {
  return request({
    url: '/v1_0/user/channels'
    // url: '/v1_1/user/channels'
  })
}

// 频道获取所有

export const allChannelsAPI = () => {
  return request({
    url: '/v1_0/channels'

  })
}

// 频道更新
export const userChannelsAPI = ({ channels }) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'PUT',
    data: {
      channels
    }
  })
}
// 获取文章列表
export const ArticleAPI = ({ channel_id, page = 1 }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id,
      timestamp: new Date().getTime(),
      with_top: 1,
      page
    }
  })
}

// 文章，不感兴趣
export const articleDislikesAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: target
    }
  })
}

// 文章搜索建议列表
export const articleSuggestionAPI = ({ q }) => {
  return request({
    url: '/v1_0/suggestion',

    params: {
      q: q
    }
  })
}
// 获取指定文章
export const articleDetailAPI = ({ artId }) => {
  return request({
    url: `/v1_0/articles/${artId}`

  })
}
// 关注作者
export const followedAPI = ({ autId }) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'post',
    data: {
      target: autId
    }

  })
}
// 文章作业-取消关注
export const unfollowedAPI = ({ autId }) => {
  return request({
    url: `/v1_0/user/followings/${autId}`,
    method: 'delete'

  })
}
// 文章点赞
export const addLikeAPI = ({ autId }) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'post',
    data: {
      target: autId
    }

  })
}
// 取消点赞
export const delLikeAPI = ({ autId }) => {
  return request({
    url: `/v1_0/article/likings/${autId}`,
    method: 'DELETE'

  })
}
// 文章  评论点赞
export const comomendLikingAPI = ({ commendId }) => {
  return request({
    url: '/v1_0/comment/likings',
    method: 'POST',
    data: {
      target: commendId
    }
  })
}
// 文章  评论取消点赞
export const comomendUnLikingAPI = ({ commendId }) => {
  return request({
    url: `/v1_0/comment/likings/${commendId}`,
    method: 'DELETE'

  })
}

// 搜索结果列表
export const searchResultAPI = ({ q, page = 1 }) => {
  return request({
    url: '/v1_0/search',

    params: {
      q: q,
      page: page
    }
  })
}
// 用户基本资料
export const userInfoAPI = () => {
  return request({
    url: '/v1_0/user'

  })
}

// 用户个人资料在编辑页面使用
export const userProfileAPI = () => {
  return request({
    url: '/v1_0/user/profile'

  })
}
// 用户更新头像
export const updataPhotoAPI = (formdata) => {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: formdata
  })
}
// 用户更新资料
export const updataProfileAPI = ({ birthday, name }) => {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data: {
      birthday: birthday,
      name: name
    }
  })
}
// 获取评论列表
export const componentListAPI = ({ artId, offset }) => {
  return request({
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset: offset
    }

  })
}
// 反馈面板 举报
export const articleReportsAPI = ({ target, type }) => {
  return request({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: target,
      type: type
    }
  })
}
